/**
 */
package org.autosar.schema.r4.impl;

import org.autosar.schema.r4.DATAELEMENTSTYPE;
import org.autosar.schema.r4.EVENTTYPE;
import org.autosar.schema.r4.R4Package;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>EVENTTYPE</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.autosar.schema.r4.impl.EVENTTYPEImpl#getSHORTNAME <em>SHORTNAME</em>}</li>
 *   <li>{@link org.autosar.schema.r4.impl.EVENTTYPEImpl#getEVENTID <em>EVENTID</em>}</li>
 *   <li>{@link org.autosar.schema.r4.impl.EVENTTYPEImpl#getDATAELEMENTS <em>DATAELEMENTS</em>}</li>
 * </ul>
 *
 * @generated
 */
public class EVENTTYPEImpl extends MinimalEObjectImpl.Container implements EVENTTYPE {
	/**
	 * The default value of the '{@link #getSHORTNAME() <em>SHORTNAME</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSHORTNAME()
	 * @generated
	 * @ordered
	 */
	protected static final String SHORTNAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getSHORTNAME() <em>SHORTNAME</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSHORTNAME()
	 * @generated
	 * @ordered
	 */
	protected String sHORTNAME = SHORTNAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getEVENTID() <em>EVENTID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEVENTID()
	 * @generated
	 * @ordered
	 */
	protected static final int EVENTID_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getEVENTID() <em>EVENTID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEVENTID()
	 * @generated
	 * @ordered
	 */
	protected int eVENTID = EVENTID_EDEFAULT;

	/**
	 * This is true if the EVENTID attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean eVENTIDESet;

	/**
	 * The cached value of the '{@link #getDATAELEMENTS() <em>DATAELEMENTS</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDATAELEMENTS()
	 * @generated
	 * @ordered
	 */
	protected DATAELEMENTSTYPE dATAELEMENTS;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EVENTTYPEImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return R4Package.Literals.EVENTTYPE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getSHORTNAME() {
		return sHORTNAME;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSHORTNAME(String newSHORTNAME) {
		String oldSHORTNAME = sHORTNAME;
		sHORTNAME = newSHORTNAME;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, R4Package.EVENTTYPE__SHORTNAME, oldSHORTNAME, sHORTNAME));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getEVENTID() {
		return eVENTID;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEVENTID(int newEVENTID) {
		int oldEVENTID = eVENTID;
		eVENTID = newEVENTID;
		boolean oldEVENTIDESet = eVENTIDESet;
		eVENTIDESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, R4Package.EVENTTYPE__EVENTID, oldEVENTID, eVENTID, !oldEVENTIDESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetEVENTID() {
		int oldEVENTID = eVENTID;
		boolean oldEVENTIDESet = eVENTIDESet;
		eVENTID = EVENTID_EDEFAULT;
		eVENTIDESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, R4Package.EVENTTYPE__EVENTID, oldEVENTID, EVENTID_EDEFAULT, oldEVENTIDESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetEVENTID() {
		return eVENTIDESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DATAELEMENTSTYPE getDATAELEMENTS() {
		return dATAELEMENTS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetDATAELEMENTS(DATAELEMENTSTYPE newDATAELEMENTS, NotificationChain msgs) {
		DATAELEMENTSTYPE oldDATAELEMENTS = dATAELEMENTS;
		dATAELEMENTS = newDATAELEMENTS;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, R4Package.EVENTTYPE__DATAELEMENTS, oldDATAELEMENTS, newDATAELEMENTS);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDATAELEMENTS(DATAELEMENTSTYPE newDATAELEMENTS) {
		if (newDATAELEMENTS != dATAELEMENTS) {
			NotificationChain msgs = null;
			if (dATAELEMENTS != null)
				msgs = ((InternalEObject)dATAELEMENTS).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - R4Package.EVENTTYPE__DATAELEMENTS, null, msgs);
			if (newDATAELEMENTS != null)
				msgs = ((InternalEObject)newDATAELEMENTS).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - R4Package.EVENTTYPE__DATAELEMENTS, null, msgs);
			msgs = basicSetDATAELEMENTS(newDATAELEMENTS, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, R4Package.EVENTTYPE__DATAELEMENTS, newDATAELEMENTS, newDATAELEMENTS));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case R4Package.EVENTTYPE__DATAELEMENTS:
				return basicSetDATAELEMENTS(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case R4Package.EVENTTYPE__SHORTNAME:
				return getSHORTNAME();
			case R4Package.EVENTTYPE__EVENTID:
				return getEVENTID();
			case R4Package.EVENTTYPE__DATAELEMENTS:
				return getDATAELEMENTS();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case R4Package.EVENTTYPE__SHORTNAME:
				setSHORTNAME((String)newValue);
				return;
			case R4Package.EVENTTYPE__EVENTID:
				setEVENTID((Integer)newValue);
				return;
			case R4Package.EVENTTYPE__DATAELEMENTS:
				setDATAELEMENTS((DATAELEMENTSTYPE)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case R4Package.EVENTTYPE__SHORTNAME:
				setSHORTNAME(SHORTNAME_EDEFAULT);
				return;
			case R4Package.EVENTTYPE__EVENTID:
				unsetEVENTID();
				return;
			case R4Package.EVENTTYPE__DATAELEMENTS:
				setDATAELEMENTS((DATAELEMENTSTYPE)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case R4Package.EVENTTYPE__SHORTNAME:
				return SHORTNAME_EDEFAULT == null ? sHORTNAME != null : !SHORTNAME_EDEFAULT.equals(sHORTNAME);
			case R4Package.EVENTTYPE__EVENTID:
				return isSetEVENTID();
			case R4Package.EVENTTYPE__DATAELEMENTS:
				return dATAELEMENTS != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuilder result = new StringBuilder(super.toString());
		result.append(" (sHORTNAME: ");
		result.append(sHORTNAME);
		result.append(", eVENTID: ");
		if (eVENTIDESet) result.append(eVENTID); else result.append("<unset>");
		result.append(')');
		return result.toString();
	}

} //EVENTTYPEImpl
